﻿namespace Arms.Persistence.Mappings
{
    using Arms.Domain;
    using System;
    using System.ComponentModel.DataAnnotations.Schema;
    using System.Data.Entity.ModelConfiguration;

    internal class EntityMap<T> : EntityTypeConfiguration<T> where T : Entity
    {
        public EntityMap()
        {
            HasKey(x => x.ID);
            Property(x => x.ID).HasColumnName(typeof(T).Name + "ID").HasDatabaseGeneratedOption(DatabaseGeneratedOption.None).HasColumnOrder(1);
            Property(x => x.ActiveState).IsRequired();
            Property(x => x.CreatedUserID).IsOptional();
            Property(x => x.UpdatedUserID).IsOptional();
            Property(x => x.Created).IsOptional();
            Property(x => x.Updated).IsOptional();
        }
    }
}
